package cn.mickey.cloud.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.mickey.cloud.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;


@Repository
public interface UserMapper extends BaseMapper<User> {


    //根据用户名查询用户
    @Select("select * from t_user where username = #{username}")
    User findUserByName(String username);

    //添加用户信息到数据库
    int addUser(User tbUser);

    // 更新密码
    @Update("update t_user set username=#{username},u_password=#{uPassword} where uid=#{uid}")
    void upp(User user);
    //查询一个
    @Select("select * from t_user where uid=#{uid}")
    User getById(long uid);


    //全查询分页

    @Select(" select * from t_user limit #{page}, #{limit}")
    List<User> page(@Param("page") int page, @Param("limit")int limit);

    //计数
    @Select("select count(uid) from t_user")
    int count();


    //单个删除
    @Delete("delete from t_user where uid = #{uid}")
    void del(long uid);


    void delList(Collection<Long> ids);
}
